package cranix.board.dao;

import java.util.ArrayList;

import cranix.common.bc.SuperBc;
import cranix.common.dao.SuperDao;
import cranix.common.util.Box;

public class ArticleDao extends SuperDao {
	public ArticleDao(SuperBc sbc) {
		super(sbc);
	}
	
	public Box<String,Object> getArticlePage() throws Exception {
		Box<String,Object> input = getInputBox();
		
		ArrayList<Object> params = new ArrayList<Object>();
		
		params.add(input.getInt("startIdx"));
		params.add(input.getInt("endIdx"));
		
		Box<String,Object> result = executeQuery("select * from articledb limit ? and ?",params);
				
		return result;
	}
	
	public Box<String,Object> getArticle() throws Exception {
		Box<String,Object> input = getInputBox();
		
		ArrayList<Object> params = new ArrayList<Object>();
		
		params.add(input.getInt("seq"));

		Box<String,Object> result = executeQuery("select * from articledb where seq=?",params);
		
		return result;
	}
	
	public int addCommentCount() throws Exception {
		Box<String,Object> input = getInputBox();
		ArrayList<Object> params = new ArrayList<Object>();
		params.add(input.getInt("seq"));
		int result = executeUpdate("update articledb set commentcount = commentcount+1 where seq=?",params);
		return result;
	}
}
